package ee.az.test.lighting;

import java.awt.Color;

/**
 * @author Artur Zinatullin (artur.zinatullin@gmail.com) 2010
 */
public class HDRColor {
	private final double r;
	private final double g;
	private final double b;

	public HDRColor(double r, double g, double b) {
		this.r = r;
		this.g = g;
		this.b = b;
	}

	public HDRColor sum(HDRColor color) {
		return new HDRColor(r + color.getRed(), g + color.getGreen(), b + color.getBlue());
	}

	public Color getColor() {
		double brightness = getBrightness();
		return new Color((float)(getRed()/brightness), (float)(getGreen()/brightness), (float)(getBlue()/brightness));
	}
	
	public double getBrightness() {
		return Math.max(Math.max(getRed(), getGreen()), getBlue());
	}
	
	public double getRed() {
		return r;
	}
	public double getGreen() {
		return g;
	}
	public double getBlue() {
		return b;
	}
}
